<ui:composition template="/WEB-INF/templates/main-template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="sidebar">
		<ui:include src="/WEB-INF/templates/public-sidebar.xhtml" />
	</ui:define>
	<ui:define name="content">
		<h:form>
			<p:growl />
			<h:outputText value="#{msg['createservice.label.heading']}" styleClass="outputTextTitle" />
			<h:panelGrid columns="3">
				<h:outputLabel value="#{msg['module.lable']} " />
				<h:outputLabel value=" : " />
				<p:selectOneMenu value="#{createServiceBean.selectedModuleId}" styleClass="adminSelectOneMenuWidth" style ="width:136px;">
						<f:selectItems value="#{createServiceBean.modulesMap}"/>
					</p:selectOneMenu>

				<h:outputLabel value="#{msg['servicename.label']} " />
				<h:outputLabel value=" : " />
				<p:inputText value="#{createServiceBean.service.serviceName}" />

				<h:outputLabel value="#{msg['displayname.label']}" />
				<h:outputLabel value=" : " />
				<p:inputText value="#{createServiceBean.service.displayName}"  />

				<h:outputLabel value="#{msg['description.label']} " />
				<h:outputLabel value=" : " />
				<p:inputTextarea value="#{createServiceBean.service.description}"  />

				<h:inputHidden />
				<h:inputHidden />


			</h:panelGrid>
			
			
			<p:commandButton value="#{createServiceBean.assignResourceButtonLabel}" actionListener="#{createServiceBean.toggleAssignPanelDisplay}" update="assignPanel" ajax="false" />
			
		<p:panel id="assignPanel" style="width: 100%" rendered="#{createServiceBean.assignResourcesToService}">
		  <h:panelGrid style="width: 100%; text-align: left; ">
			<p:dataTable value="#{createServiceBean.resources}" var="row" selectionMode="multiple" rowKey="#{row.resourceId}" selection="#{createServiceBean.selectedResources}">
				<p:column>
					<f:facet name="header">
						<h:outputText value="Resource Name" />
					</f:facet>
					<h:outputText value="#{row.resourceName}" />
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="File Name" />
					</f:facet>
					<h:outputText value="#{row.fileName}" />
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Display Name" />
					</f:facet>
					<h:outputText value="#{row.displayName}" />
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Description" />
					</f:facet>
					<h:outputText value="#{row.description}" />
				</p:column>	

			</p:dataTable>			
			<p:commandButton value="Assign selected Resources" style="float: right;" actionListener="#{createServiceBean.assignResourceAction}" update="@form"/>
			
				<h:outputText value="Service Resouces Details"
					styleClass="outputTextSubTitle" />
				<p:dataTable value="#{createServiceBean.assignResources}" var="row" binding="#{createServiceBean.assignedResourcesTable}">
					<p:column>
						<f:facet name="header">
							<h:outputText value="Resource Name" />
						</f:facet>
						<h:outputText value="#{row.resourceName}" />
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="File Name" />
						</f:facet>
						<h:outputText value="#{row.fileName}" />
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="Display Name" />
						</f:facet>
						<h:outputText value="#{row.displayName}" />
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="Description" />
						</f:facet>
						<h:outputText value="#{row.description}" />
					</p:column>
					<p:column style="text-align: center;">
						<f:facet name="header">
							<h:outputText value="Start page" />
						</f:facet>
						<p:selectBooleanCheckbox value="#{row.selected}"/>
					</p:column>
					<p:column style="text-align: center; width: 30px;">
						<p:commandButton icon="ui-icon-close" title="Remove from list"
							actionListener="#{createServiceBean.removeService}"
							update="@form" style="padding: 0"/>
					</p:column>
				</p:dataTable>
			</h:panelGrid>
			</p:panel>
				<p:commandButton value="Save Service" actionListener="#{createServiceBean.saveService}" ajax="false" />
			

		</h:form>
	</ui:define>
</ui:composition>

